package com.atguigu.multiReading;

import java.util.concurrent.atomic.AtomicInteger;

public class demo17 {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger count=new AtomicInteger(0);
        Thread t1=new Thread(()->{
            for(int i=0;i<50000;i++){
                //相当于count++
                count.getAndIncrement();
                //相当于++count
               // count.incrementAndGet();
                ///--count
               // count.decrementAndGet();
                //count--
                //count.getAndDecrement();
            }
        });
        Thread t2=new Thread(()->{
            for(int i=0;i<50000;i++)
            count.getAndIncrement();
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(count.get());
    }
}
